package com.example.demo.controller;

import com.example.demo.entity.Compression;
import com.example.demo.service.DataCompressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description
 * @Author chenhuiyu
 * @Date 2023/12/18
 */
@RestController
@RequestMapping(value = "/compress")
public class DataCompressController {
    @Autowired
    private DataCompressService dataCompressService;

    @PostMapping("/snappy/add")
    public void dataSnappy(@RequestBody Compression compression) {
        if (!compression.getData().isEmpty()) {
            dataCompressService.dataCompress(compression);
        }
    }

    @PostMapping("/snappy/read")
    public String readData(Integer id) {
        return dataCompressService.readData(id);

    }
}
